import { createAsyncThunk } from "@reduxjs/toolkit";
import Request from "http/Request";
import {PagingData, PagingResult} from "type/Page";
import {ReportDetail} from "type/entity/ReportDetail";

/** 请求报销单详细信息表分页数据 */
export const fetchReportDetailPageData = createAsyncThunk(
    'reportDetail/fetchReportDetailPageData',
    async (paging: PagingData) => {
        return await Request.get<PagingResult<ReportDetail>>("/record/report_detail/page/" + paging.page + "/" + paging.pageSize);
    }
);

/** 添加报销单详细信息表数据 */
export const fetchAddReportDetail = createAsyncThunk(
    'reportDetail/fetchAddReportDetail',
    async (vo: ReportDetail) => {
       return await Request.put<number>("/record/report_detail", vo);
    }
);

/** 更新报销单详细信息表数据 */
export const fetchUpdateReportDetail = createAsyncThunk(
    'reportDetail/fetchUpdateReportDetail',
    async (vo: ReportDetail) => {
        return await Request.post<number>("/record/report_detail", vo);
    }
);

/** 删除报销单详细信息表数据 */
export const fetchDeleteReportDetail = createAsyncThunk(
    'reportDetail/fetchDeleteReportDetail',
    async (id: number) => {
        return await Request.delete<number>("/record/report_detail" + id);
    }
);

